package com.ff.neuropp.domain;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ff.neuropp.util.DateSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Data
@Entity
@Table(name = "t_order", uniqueConstraints = {@UniqueConstraint(columnNames="id")})
/**
 * 职业生涯表
 * @author sun_weiwu
 *
 */
public class Order {
	 private static final long serialVersionUID = 1L;

	 
	   @Id
	    @GeneratedValue(strategy = GenerationType.IDENTITY)
	    private int id;
	 
	    @Column(name = "order_num", columnDefinition = "varchar(100) COMMENT '订单号'")
	    @ApiModelProperty(value = "订单号")
	    private String orderNum;


	    @Column(name = "course_name", columnDefinition = "varchar(100) COMMENT '课程名称'")
	    @ApiModelProperty(value = "课程名称")
	    private String CourseName;

	    @Column(name = "order_status", columnDefinition = "int(11) COMMENT '订单状态'")
	    @ApiModelProperty(value = "订单状态 0 预支付 1 支付成功  2 支持失败")
	    private Integer orderStatus=0;

	    @Transient
	    private IosUser iosUser;

	    @Column(name = "user_id")
	    @ApiModelProperty(value = "购买人")
	    private String userId;

	    
	    @Column(name = "amount", columnDefinition = "decimal(20,4) COMMENT '支付金额'")
	    @ApiModelProperty(value = "支付金额")
	    private BigDecimal amount ; 
	    
	    @Column(name = "paid_type", columnDefinition = "varchar(100) COMMENT '支付方式'")
	    @ApiModelProperty(value = "支付方式 ")
	    private String paidType ;


		@OneToOne
		@JoinColumn(name = "course_id")
		@ApiModelProperty(value = "课程Id")
		private Course course;
	    
	    //操作时间
	    @Column(updatable = false)
	    @org.hibernate.annotations.CreationTimestamp
	    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	    @JsonSerialize(using = DateSerializer.class)
	    private Date create_date;
	    
	    @Column(name = "update_time", columnDefinition = "datetime COMMENT '更新时间'")
	    private Date updateTime;
	    
}
